from selenium.webdriver.common.by import By

from xueqiu_app_po.page.my_page import MyPage
from xueqiu_app_po.page.search_page import SearchPage
from xueqiu_app_po.base.xueqiu_app import XueQiuApp
from xueqiu_app_po.page.market_quotations import MarketQuotations


class MainPage(XueQiuApp):
    _SEARCH = By.ID, "com.xueqiu.android:id/home_search"
    _XIAN = By.XPATH, "//*[@text ='行情']"
    _MY = By.XPATH,"//*[@text = '我的']"

    # 点击顶部栏【搜索框】
    def click_top_search(self):
        # 定位到搜索按钮并点击
        self.find_and_click(*self._SEARCH)
        return SearchPage(self.driver)

    # 点击主业行情
    def click_market_quotations(self):
        self.find_and_click(*self._XIAN)
        return MarketQuotations(self.driver)
    def click_my(self):
        self.find_and_click(*self._MY)
        return MyPage(self.driver)
